#include <jsoncpp/json/json.h>
#include <iostream>

int main()
{
    std::string json = R"({"name": "zhangsan","age": 18,"score":[77.5, 88.5, 99.5]})";
    Json::CharReaderBuilder builder;

    std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
    Json::Value val;
    std::string errors;
    bool ret = reader->parse(json.c_str(), json.c_str() + json.size(), &val, &errors);
    if(!ret)
    {
        std::cout << "parse json failed" << std::endl;
        return -1;
    }
    std::cout << val["name"].asString() << std::endl;
    std::cout << val["age"].asInt() << std::endl;
    if(!val["score"].isNull() && val["score"].isArray())
    {
        int sz = val["score"].size();
        for(int i = 0; i < sz; i++)
        {
            std::cout << val["score"][i].asDouble() << std::endl;
        }
    }
    return 0;
}
